/**
 * Datenbankverbindung
 * @author admin
 */
package DataBase;

import java.sql.*;

/**
 *
 * @author admin
 */
public class DBConnection {
    private static String servername = "localhost";
    private static int portNumber = 5432;
    private static String database = "temprom";
    private static String dbUser = "postgres";
    private static String dbUserPw = "Pa55word";

    
    /**
     *
     * @return
     * Verbindung Herstellen von Parmater übergabe
     */
    public static Connection CreateConnection()
    {
        try
        {
           Class.forName("org.postgresql.Driver"); //Buch s. 345
           
           // Verbindung zur Datenbank zurückgeben
           return DriverManager.getConnection("jdbc:postgresql://" 
                   + servername 
                   + ":" 
                   + portNumber 
                   + "/" + database,
                   dbUser,
                   dbUserPw);
        } 
        catch (ClassNotFoundException | SQLException e)
        {
            System.out.println(e);
            return null;
        }
    }
}
